<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../resources/js-test.js"></script>
</head>
<body>
<script>

description("Test OffscreenCanvas transferable with exception cases.");
window.jsTestIsAsync = true;

var worker = new Worker('./resources/OffscreenCanvas-transferable.js');

var width = 50;
var height = 50;
var canvas = document.createElement("canvas");
canvas.width = width;
canvas.height = height;
var newOffscreenCanvas;

var offscreenCanvas = canvas.transferControlToOffscreen();
shouldBe("offscreenCanvas.width", "width");
shouldBe("offscreenCanvas.height", "height");

worker.postMessage({data: offscreenCanvas}, [offscreenCanvas]);
shouldBe("offscreenCanvas.width", "0");
shouldBe("offscreenCanvas.height", "0");

worker.onmessage = function(e) {
    newOffscreenCanvas = e.data.data;
    shouldBe("newOffscreenCanvas.width", "width");
    shouldBe("newOffscreenCanvas.height", "height");
    finishJSTest();
}
</script>
</body>
</html>
